﻿import QtQuick 2.0
import QtQuick.Window 2.2
import QtQuick.Controls 1.4

Item {
    id: root
    width: Screen.width
    height: Screen.height

    property string effectSource

    Component.onCompleted: {
//        contentLoader.item.source = "qrc:/girl.png"
        effectSource = "EffectRipple.qml"
    }

    onEffectSourceChanged: {
        effectLoader.source = effectSource
        effectLoader.item.parent = root
        effectLoader.item.targetWidth = root.width
        effectLoader.item.targetHeight = root.height
        updateSource()
        effectLoader.item.source = theSource

        parameterPanel.model = content.effect.parameters
    }

    function updateSource() {
        if (contentLoader.item) {
            contentLoader.item.parent = root
            contentLoader.item.anchors.fill = root
            theSource.sourceItem = contentLoader.item
            if (effectLoader.item)
                effectLoader.item.anchors.fill = contentLoader.item
        }
    }

    Rectangle{
        id: content
        anchors.fill: parent
        color: "transparent"

        property alias effect: effectLoader.item

        ShaderEffectSource {
            id: theSource
            smooth: true
            hideSource: true
        }

        //img, video
        Loader{
            id: contentLoader
            source: ""
        }

        Loader {
            id: effectLoader
            source: effectSource
        }
    }

    ParameterPanel {
        id: parameterPanel
        z: 100
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 100
        gripSize: 20
        visible: false
    }
}
